package social.hub.impl.scribe.util;

import org.scribe.builder.api.DefaultApi10a;
import org.scribe.model.Token;

import social.hub.oauth.OAuthConfig;
import social.hub.util.Utils;

public class GenericScribe10aAPI extends DefaultApi10a {

	private final OAuthConfig config;

	public GenericScribe10aAPI(OAuthConfig config) {
		this.config = config;
	}

	@Override
	public String getAccessTokenEndpoint() {
		return Utils.createUrlBuilder(config.getAccessTokenUrl(), config).toString();
	}

	@Override
	public String getAuthorizationUrl(Token requestToken) {
		return Utils.createUrlBuilder(config.getAuthorizeUrl(), config)
				.addQueryParan("oauth_token", requestToken.getToken()).toString();
	}

	@Override
	public String getRequestTokenEndpoint() {
		return Utils.createUrlBuilder(config.getRequestTokenUrl(), config).toString();
	}

}